package com.sino.operation.peripheral;

import java.lang.reflect.Method;
import java.util.Map;

/**
 * @Title: InteractiveFactory
 * @Description: 根据类型与接口号调用外围接口类拼装并发送报文
 * @Author dengls
 * @date 2021/9/22 10:43
 */
public class InteractiveFactory {
    //删除代码核心与二代支付接口类包路径字段 所有的外围接口维护在同一个包路径下 添加统一的包路径字段
    private static String path = "com.sino.operation.peripheral.kernel";//核心接口类包路径

    /**
     * @param code      接口号
     * @param map       当前报文
     * @param acceptMap 网点受理岗报文
     * @param paramMap  动态参数map对象
     * @return ESC返回报文
     * @throws Exception
     */
    public static String executeInteractive(String code, Map<String, Object> map, Map<String, Object> acceptMap, Map<String, String> paramMap) throws Exception {
        Class clz = Class.forName(path + ".ESC_" + code);
        Method method = clz.getMethod("executeInteractive", Map.class, Map.class, Map.class);
        String receiveStr = (String) method.invoke(clz.newInstance(), map, acceptMap, map);
        return receiveStr;
    }
}
